﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script src="/js/header.js"></script>
</head>
<body style="background-color: white;">
    <section class="container-fluid" style="background-color: white;">
        <form class="form-horizontal m15_t" id="form">
            <div class="tab-content">
                <div class="tab-pane fade in active" id="home">
                    <input type="hidden" name="bcid" value="0">
                    <div class="form-group">
                        <label class="wd125 control-label">虚拟机编码：</label>
                        <div>
                            <input class="form-control wd250" type="text" name="vmClientId" maxlength="32" autocomplete="off" placeholder="虚拟机编码" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd125 control-label">备注：</label>
                        <div class="">
                            <input class="form-control wd250" type="text" name="remark" maxlength="50" autocomplete="off">
                        </div>
                    </div>
                </div>
            </div>
        </form>

    </section>

    <script type="text/javascript">
        var id = 0;
        $(function () {
            id = FlashPay.Util.GetQueryString("id");
            init(id);
        })

        function init(id) {
            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/Receipt/GetReceiptCard?bcId=" + id,
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    FlashPay.Util.SetInputVal("bcid", res.bcid);
                    FlashPay.Util.SetInputVal("vmClientId", res.vmClientId);
                    FlashPay.Util.SetInputVal("remark", res.remark);
                    cover.Remove();
                }
            });
        }

        function save() {
            var data = $("#form").serializeObject();

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });
            FlashPay.Util.Ajax({
                type: "POST",
                url: "/Receipt/ReceiptCardEdit",
                data: data,
                success: function (response) {
                    if (response.success) {
                        cover.Remove();
                        FlashPay.UI.Tip_success(data.successMessage == null ? "操作成功！" : data.successMessage);
                        FlashPay.UI.DialogOpener().doSearch();
                        FlashPay.UI.CloseDialog();
                    } else {
                        cover.Remove();
                        FlashPay.UI.Tip_short_warning("操作失败！" + response.errorMessage);
                    }
                },
                error: function (json) {
                    cover.Remove();
                    FlashPay.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });
        }

        $.fn.serializeObject = function () {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function () {
                if (o[this.name] !== undefined) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        };
    </script>
</body>
</html>